package com.iotechn.unimall.data.dto.warehouse;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import com.iotechn.unimall.data.domain.SkuDO;
import com.iotechn.unimall.data.dto.SuperDTO;
import lombok.Data;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;

/**
 * 入库商品
 */
@ExcelTarget("purchaseWarehouseOrderGoodsDTO")
@Data
public class PurchaseWarehouseOrderGoodsDTO extends SuperDTO implements Serializable {

    //入库单号
    @Excel(name = "单号", width = 20d)
    private String warehouseOrderNo;

    private Long warehouseOrderId;

    private Long warehouseId;

    //仓库已有库存
    private Float warehouseSkuNum;


    private Long warehouseGoodsTax;


    private Long goodsId;

    private String goodsName;

    private String goodsNo;

    private String goodsSpec;
    @Excel(name = "名称")
    private String spuName;
    @Excel(name = "规格")
    private String skuName;
    private String goodsUnit;
    @Excel(name = "条码", width = 20d)
    private String barCode;

    private String img;
    @Excel(name = "单位")
    private String unit;
    @Excel(name = "数量")
    private Float warehouseGoodsBuyNum;
    @Excel(name = "单价")
    private Float warehouseGoodsPrice;
    @Excel(name = "总价")
    private Float warehouseGoodsAmount;
    private Float goodsTotalPrice;
    private String goodsImg;

    private String goodsBarCode;


    private Long skuId;

    private Long spuId;


    @Excel(name = "状态", replace = {"待入库_0", "已入库_1", "驳回_-1", " _ "})
    private Integer warehouseOrderState;
    @Excel(name = "仓库")
    private String warehouseName;
    @Excel(name = "供应商")
    private String supplierName;
    //记录入库后的平均价
    private Float goodsAverPrice;

    private Float averPrice;
    //记录入库前的平均价
    private Float goodsPreAverPrice;

    @Excel(name = "制单日期", databaseFormat = "yyyyMMddHHmmss", format = "yyyy-MM-dd HH:mm:ss")
    private Date gmtCreate;

    //入库单子审批时间
    private Date warehouseOrderAuditTime;//

    public Float getGoodsTotalPrice() {
        if (this.warehouseGoodsBuyNum == null || this.warehouseGoodsPrice == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format((this.warehouseGoodsBuyNum * this.warehouseGoodsPrice));
        return Float.valueOf(total);
    }

    private List<SkuDO> skuDOList;
}
